package y2019.date0927.notifywaite;

import org.junit.jupiter.api.Test;
import y2019.date0927.notifywaite.base.BasePCModel;

/**
 * 生产者消费者model。不加锁
 *
 * @author lu
 * @date 2019-09-27
 */
public class ProductConsumerModel_0 extends BasePCModel {

    private final int count = 10;
    private Object lock = new Object();
    private String name = "苹果";
    private int productNo = 0;//苹果编号

    @Test
    public void produce() {
        for (int i = 0; i < count; i++) {
            //编号增加，模拟制作不同编号苹果，方便理解，制作过程的业务逻辑省略
            productNo++;
            System.out.println(String.format("生产中，%s编号%d", name, productNo));
        }
    }

    @Test
    public void consume() {
        for (int i = 0; i < count; i++) {
            System.out.println(String.format("消费中，%s编号%d", name, productNo));
        }

    }


}
